Здравствуйте, помогите пожалуйста разобраться с отправкой файла. вот код...
function captcha_()
{
var http = new XMLHttpRequest();
var url = 'http://antigate.com/design/grey2/alogo.gif';
http.open("GET", url, false);
http.onreadystatechange = function()
{
if (http.readyState == 4 && http.status == 200)
{
var httpRequest = new XMLHttpRequest();
var boundary = '-----564AaB03x';
var requestBody = "--" + boundary + "\r\n" +
"Content-Disposition: form-data; name=\"method\"\r\n" +
"\r\n" +
"post\r\n" +
"--" + boundary + "\r\n" +
"Content-Disposition: form-data; name=\"key\"\r\n" +
"\r\n" +
'КЛЮЧ' + "\r\n" +
"--" + boundary + "\r\n" +
"Content-Disposition: form-data; name=\"file\"; filename=\"alogo\.gif\"\r\n" +
"Content-Type: image/gif\r\n" +
"\r\n" +
http.responseText +
"\r\n" +
"--" + boundary + "--"
;
httpRequest.open('POST', 'http://antigate.com/in.php', true);
httpRequest.setRequestHeader('Content-Type','multipart/form-data; boundary=' + boundary);
httpRequest.setRequestHeader("Content-length", requestBody.length);
//httpRequest.setRequestHeader("Accept", "*/*");
httpRequest.send(requestBody);
httpRequest.onreadystatechange=function()
{
if(httpRequest.readyState == 4)
{
if (httpRequest.status == 200)
alert(httpRequest.responseText);
else alert("Ошибка обработки запроса!");
}
}
}
}
http.send(null);
}
мне нужно отправить содержимое ФАЙЛА капчи, БЕЗ какого либо кодирования, целиком.
Алерт выдает ошибку ERROR_ZERO_CAPTCHA_FILESIZE, подозреваю что это из-за кодировки получаемых через GET данных, подскажите пожалуйста как исправить ошибку